//
//  Reference.m
//  PokerPlus
//
//  Created by Lv Changye on 11-8-5.
//  Copyright 2011年 Lv Changye. All rights reserved.
//

#import "Reference.h"


@implementation Reference

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [jieMian release];
    [mingCi release];
    [jinBiaoSai release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    
    UIScrollView *_scroll=[[UIScrollView alloc]initWithFrame:CGRectMake(39, 97,824, 358)];
    _scroll.backgroundColor=[UIColor clearColor];
    [_scroll.layer setCornerRadius:3.0];
    [self.view addSubview:_scroll];
    _scroll.delegate=self;
    _scroll.decelerationRate=2.5;
    _scroll.contentSize=CGSizeMake(824*3, 358);
    _scroll.pagingEnabled=YES;
    _scroll.showsHorizontalScrollIndicator=NO;
    UIImageView *jie1=[[UIImageView alloc]initWithFrame:CGRectMake(60, 35, 685, 286)];
    jie1.image=[UIImage imageNamed:@"界面介绍.png"];
    jie1.backgroundColor=[UIColor clearColor];
    [_scroll addSubview:jie1];
    [jie1 release];
    
    UIImageView *jie2=[[UIImageView alloc]initWithFrame:CGRectMake(824+40, 35, 737, 254)];
    jie2.image=[UIImage imageNamed:@"名词解释.png"];
    jie2.backgroundColor=[UIColor clearColor];
    [_scroll addSubview:jie2];
    [jie2 release];
   
    UIImageView *jie3=[[UIImageView alloc]initWithFrame:CGRectMake(824*2+20, 35, 789, 171)];
    jie3.image=[UIImage imageNamed:@"锦标赛资料.png"];
    jie3.backgroundColor=[UIColor clearColor];
    [_scroll addSubview:jie3];
    [jie3 release];
    
    scroll=_scroll;
    //[_scroll release];
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)viewDidUnload
{
    [jieMian release];
    jieMian = nil;
    [mingCi release];
    mingCi = nil;
    [jinBiaoSai release];
    jinBiaoSai = nil;
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)jieMianJieShao:(id)sender {
    [jieMian setImage:[UIImage imageNamed:@"界面介绍点中.png"] forState:UIControlStateNormal];
    [mingCi setImage:[UIImage imageNamed:@"名词解释未点中.png"] forState:UIControlStateNormal];
    [jinBiaoSai setImage:[UIImage imageNamed:@"锦标赛未点中.png"] forState:UIControlStateNormal];
    [scroll setContentOffset:CGPointMake(0, 0) animated:YES];
    
    
}

- (IBAction)mingCiJieShi:(id)sender {
    [jieMian setImage:[UIImage imageNamed:@"界面介绍未点中.png"] forState:UIControlStateNormal];
    [mingCi setImage:[UIImage imageNamed:@"名词解释点中.png"] forState:UIControlStateNormal];
    [jinBiaoSai setImage:[UIImage imageNamed:@"锦标赛未点中.png"] forState:UIControlStateNormal];
    [scroll setContentOffset:CGPointMake(824, 0) animated:YES];
}

- (IBAction)jinBiaoSaiShuoMing:(id)sender {
    [jieMian setImage:[UIImage imageNamed:@"界面介绍未点中.png"] forState:UIControlStateNormal];
    [mingCi setImage:[UIImage imageNamed:@"名词解释未点中.png"] forState:UIControlStateNormal];
    [jinBiaoSai setImage:[UIImage imageNamed:@"锦标赛说明点中.png"] forState:UIControlStateNormal];
    [scroll setContentOffset:CGPointMake(824*2, 0) animated:YES];
}

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    float f=scrollView.contentOffset.x;
    int i=f/824+1;
    
    switch (i) {
        case 1:
        {
            [jieMian setImage:[UIImage imageNamed:@"界面介绍点中.png"] forState:UIControlStateNormal];
            [mingCi setImage:[UIImage imageNamed:@"名词解释未点中.png"] forState:UIControlStateNormal];
            [jinBiaoSai setImage:[UIImage imageNamed:@"锦标赛未点中.png"] forState:UIControlStateNormal];
            break;
        }
        case 2:{
            [jieMian setImage:[UIImage imageNamed:@"界面介绍未点中.png"] forState:UIControlStateNormal];
            [mingCi setImage:[UIImage imageNamed:@"名词解释点中.png"] forState:UIControlStateNormal];
            [jinBiaoSai setImage:[UIImage imageNamed:@"锦标赛未点中.png"] forState:UIControlStateNormal];
            break;
        }
        case 3:{
            [jieMian setImage:[UIImage imageNamed:@"界面介绍未点中.png"] forState:UIControlStateNormal];
            [mingCi setImage:[UIImage imageNamed:@"名词解释未点中.png"] forState:UIControlStateNormal];
            [jinBiaoSai setImage:[UIImage imageNamed:@"锦标赛说明点中.png"] forState:UIControlStateNormal];
            break;
        }
           
        default:
            break;
    }

}


@end
